package uform.ui.assembler;
import uform.ui.comp.Component;
import thx.validation.RangeValidator;
import uform.ui.comp.NumberControl;
import uform.model.value.FloatType;
using Types;

class FloatTypeAssembler extends BaseAssembler<FloatType<Float>>
{
	override public function assemble(type : FloatType<Float>) : Component
	{
		var options = _options(type);
		if (null != options)
			return options;
		var control = new NumberControl("");
		for (validator in type.validators)
		{
			validator.ifIs(RangeValidator, function(v) {
				control.min.set(v.min);
				control.minInclusive.set(v.minInclusive);
				control.max.set(v.max);
				control.maxInclusive.set(v.maxInclusive);
			});
			// TODO add "step" attribute using IncrementValidator and IntType
		}
		_bindBidirectional(control);
		return control;
	}
}